using UnityEngine;
using System.Collections;

//Singlton class
public class csCameraSawCheckingTool
{	
	static csCameraSawCheckingTool mInstance = null;		//Self
	
	protected Camera 	mMainCam 		= null;						//Main Camera
	protected Plane[]	mBoundPlanes;								//Bound planes around camera
	
	public static csCameraSawCheckingTool GetInstance()
	{
		if(mInstance == null)
			mInstance = new csCameraSawCheckingTool();
		
		return mInstance;
	}
	
	
	public bool IsGameObjectInCameraView(Bounds bound)
	{
		if(this.mMainCam == null) {
			mMainCam 		= Camera.main;
			mBoundPlanes	= GeometryUtility.CalculateFrustumPlanes(this.mMainCam);						
		}
		
		return GeometryUtility.TestPlanesAABB(this.mBoundPlanes, bound);
	}
}
